<?php

namespace app\modules\clinical\models;

use Yii;

/**
 * This is the model class for table "hspt_relation".
 *
 * @property integer $relation_id
 * @property integer $pt_left
 * @property integer $relation_type
 * @property integer $pt_right
 * @property string $crt_name
 * @property string $crt_time
 * @property integer $update_at
 * @property integer $update_name
 * @property integer $delete_at
 */
class HsptRelation extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'hspt_relation';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['pt_left', 'relation_type', 'pt_right', 'crt_time'], 'required'],
            [['pt_left', 'relation_type', 'pt_right', 'update_at', 'update_name', 'delete_at'], 'integer'],
            [['crt_time'], 'safe'],
            [['crt_name'], 'string', 'max' => 255]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'pt_left' => 'Pt Left',
            'relation_type' => 'Relation Type',
            'pt_right' => 'Pt Right',
            'crt_name' => 'Crt Name',
            'crt_time' => 'Crt Time',
            'update_at' => 'Update At',
            'update_name' => 'Update Name',
            'delete_at' => 'Delete At',
        ];
    }

    public static function getParams($type = false, $code = false) {
        $params = [
            'relation' => ['0' => '本人', '1' => '配偶', '2' => '父亲', '3' => '母亲', '4' => '女儿', '5' => '儿子', '6' => '哥哥', '7' => '姐姐', '8' => '弟弟', '9' => '妹妹', '10' => '其他亲属'],
        ];

        if ($code !== false) {
            return ($type) ? $params[$type][$code] : '';
        }

        return ($type) ? $params[$type] : [];
    }
}
